package br.com.viamais.infra.dao;

import java.io.Serializable;
import java.util.List;

import br.com.viamais.infra.model.BaseEntity;

/**
 * <B>Project: viamais-web</B><BR>
 * 
 * Base interface for DAO basic CRUD operations.
 * 
 * <DL>
 * <DT><B>Created:</B>
 * <DD>Sep 18, 2011</DD></DT>
 * </DL>
 * <DL>
 * <DT><B>Last Modification:</B>
 * <DD>Sep 18, 2011</DD></DT>
 * </DL>
 * 
 * @author Caio Carleto - CarSer - Sep 18, 2011
 * @version 1.0
 */
public interface IBaseDAO<T extends BaseEntity> extends Serializable {

	/**
	 * Method to save any entity.
	 * 
	 * @param <T>
	 * @param entity
	 *            - T
	 * @return entity - T
	 * @throws Throwable: Connections database errors 
	 */
	public void saveOrUpdate(final T entity) throws Throwable;

	/**
	 * Method to delete entities that already exists.
	 * 
	 * @param <T>
	 * @param entity
	 *            - T
	 * @return boolean
	 * @throws Throwable: Connections database errors 
	 */
	public void delete(final T entity) throws Throwable;

	/**
	 * Method to list all entities type of database.
	 * 
	 * @param <T>
	 * @param entity- T
	 * @return entities - List<T>
	 * @throws Throwable: Connections database errors 
	 */
	public List<T> getAll() throws Throwable;

	/**
	 * Method to get a entity in database.
	 * 
	 * @param <T>
	 * @param id
	 * @return entity - T.
	 * @throws Throwable: Connections database errors 
	 */
	public T getById(final Integer id) throws Throwable;

	/**
	 * Method to load a entity proxy.
	 * @param id
	 * @return entity - T.
	 * @throws Throwable: Connections database errors 
	 */
	public T load(Integer id) throws Throwable;

}
